package com.test.kotlin.ui.adapter

import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import com.blankj.utilcode.util.ScreenUtils
import com.blankj.utilcode.util.SizeUtils
import com.bumptech.glide.Glide
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.test.kotlin.R
import com.test.kotlin.bean.HomeVenue


class VenueAdapter :BaseQuickAdapter<HomeVenue,BaseViewHolder>(R.layout.layout_home_venue_item){

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BaseViewHolder {
        var holder=super.onCreateViewHolder(parent, viewType)

        var ivImg=holder.getView<View>(R.id.iv_venue_img)
        ivImg.layoutParams.width=(ScreenUtils.getScreenWidth() - SizeUtils.dp2px(15f)) / 9 * 8
        ivImg.requestLayout()
        return holder
    }

    override fun convert(holder: BaseViewHolder, item: HomeVenue) {
        with(item){
            holder.setText(R.id.tv_venue_title,venue?.recommendName)

            var ivImage:ImageView=holder.getView(R.id.iv_venue_img)
            Glide.with(ivImage)
                .load(venue?.posterImg)
                .centerCrop()
                .placeholder(R.drawable.place_holder)
                .into(ivImage)
        }
    }
}